﻿using System;
using UnityEngine;

public abstract class BaseUpgrade : ScriptableObject, IUpgrade
{
    [SerializeField]
    protected UpgradeType upgradeType;
    public UpgradeType UpgradeType => upgradeType;

    [SerializeField]
    protected string title;
    public string Title => title;

    [SerializeField]
    protected Sprite icon;
    public Sprite Icon => icon;

    [NonSerialized]
    protected int upgradeLevel;
    public int UpgradeLevel => upgradeLevel;

    public abstract BaseUpgradeStage[] Upgrades { get; }

    public abstract void Initialise();
    public abstract void UpgradeStage();

    public virtual void Load(UpgradeSavableObject savableObject)
    {
        upgradeLevel = savableObject.UpgradeLevel;
    }

    public virtual UpgradeSavableObject Save()
    {
        return new UpgradeSavableObject(upgradeType, upgradeLevel);
    }
}
